/*
 * @Author: Yuluo 568055454@qq.com
 * @Date: 2023年06月16日 23:18:06
 * @LastEditors: Yuluo 568055454@qq.com
 * @LastEditTime: 2023年07月06日 01:53:58
 * @FilePath: \Mood-Blog-System\back\config\index.js
 * @Description: 配置文件，用于存放全局配置信息 
 * Copyright (c) 2023 by Yuluo, All Rights Reserved. 
 */
const config = {
    nodeEnv: process.env.NODE_ENV || 'development',
    defaultAvatar: `http://${process.env.DB_HOST}:${process.env.SERVER_PORT}/avatar.jpg`,
    defaultCover: `http://${process.env.DB_HOST}:${process.env.SERVER_PORT}/cover.jpg`,
    staticPath: process.env.STATIC_PATH,
    auth: process.env.Auth,
    server: {
        port: process.env.SERVER_PORT
    },
    db: {
        name: process.env.DB_NAME,
        host: process.env.DB_HOST,
        port: process.env.DB_PORT,
        user: process.env.DB_USER,
        password: process.env.DB_PASSWORD,
        debug: process.env.DB_DEBUG,
        timezone: 'Asia/Shanghai',
        opts: {
            useNewUrlParser: true, // 使用新的url解析器
            useUnifiedTopology: true, // 使用新的服务器发现和监视引擎
            autoIndex: false, // 禁用索引建立
            authSource: "admin",
            retryWrites: true,
            w: "majority",
            replicaSet: 'rs0'
        }
    },
    jwt: {
        secret: process.env.JWT_SECRET,
        expiresIn: process.env.JWT_EXPIRES_IN
    },
    // type: trace, debug, info, warn, error, fatal
    log: [
        { name: 'access', level: 'info' },
        { name: 'response', level: 'info' },
        { name: 'db', level: 'info' },
    ],
    email: {
        sender: process.env.QQ_EMAIL_SENDER,
        authCode: process.env.QQ_AUTH_CODE,
        expireTime: process.env.EMAIL_CODE_EXPIRE_TIME * 1
    },
    errorRes: {
        noUser: { code: 400, message: '用户不存在' },
        noUsername: { code: 401, message: '用户名错误' },
        noPassword: { code: 402, message: '密码错误' },
        noPermission: { code: 403, message: '没有权限' },
        noFound: { code: 404, message: '资源不存在' },
        hasUser: { code: 405, message: '用户已存在' },
        hasUsername: { code: 406, message: '用户名已存在' },
        hasEmail: { code: 407, message: '邮箱已存在' },
        hasPhone: { code: 408, message: '手机号已存在' },
        addError: { code: 409, message: '添加失败' },
        updateError: { code: 410, message: '更新失败' },
        deleteError: { code: 411, message: '删除失败' },
        queryError: { code: 412, message: '查询失败' },
        serverError: { code: 500, message: '服务器错误' },
    }
}


module.exports = config;